/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Tbv_bitacora_recaudacionDAOImpl implements orm.dao.Tbv_bitacora_recaudacionDAO {
	public Tbv_bitacora_recaudacion loadTbv_bitacora_recaudacionByORMID(int br_id_bitacora_recaudacion) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_recaudacionByORMID(session, br_id_bitacora_recaudacion);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion getTbv_bitacora_recaudacionByORMID(int br_id_bitacora_recaudacion) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return getTbv_bitacora_recaudacionByORMID(session, br_id_bitacora_recaudacion);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion loadTbv_bitacora_recaudacionByORMID(int br_id_bitacora_recaudacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_recaudacionByORMID(session, br_id_bitacora_recaudacion, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion getTbv_bitacora_recaudacionByORMID(int br_id_bitacora_recaudacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return getTbv_bitacora_recaudacionByORMID(session, br_id_bitacora_recaudacion, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion loadTbv_bitacora_recaudacionByORMID(PersistentSession session, int br_id_bitacora_recaudacion) throws PersistentException {
		try {
			return (Tbv_bitacora_recaudacion) session.load(orm.Tbv_bitacora_recaudacion.class, new Integer(br_id_bitacora_recaudacion));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion getTbv_bitacora_recaudacionByORMID(PersistentSession session, int br_id_bitacora_recaudacion) throws PersistentException {
		try {
			return (Tbv_bitacora_recaudacion) session.get(orm.Tbv_bitacora_recaudacion.class, new Integer(br_id_bitacora_recaudacion));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion loadTbv_bitacora_recaudacionByORMID(PersistentSession session, int br_id_bitacora_recaudacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tbv_bitacora_recaudacion) session.load(orm.Tbv_bitacora_recaudacion.class, new Integer(br_id_bitacora_recaudacion), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion getTbv_bitacora_recaudacionByORMID(PersistentSession session, int br_id_bitacora_recaudacion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tbv_bitacora_recaudacion) session.get(orm.Tbv_bitacora_recaudacion.class, new Integer(br_id_bitacora_recaudacion), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion[] listTbv_bitacora_recaudacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return listTbv_bitacora_recaudacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion[] listTbv_bitacora_recaudacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return listTbv_bitacora_recaudacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion[] listTbv_bitacora_recaudacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_recaudacion as Tbv_bitacora_recaudacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Tbv_bitacora_recaudacion[]) list.toArray(new Tbv_bitacora_recaudacion[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion[] listTbv_bitacora_recaudacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_recaudacion as Tbv_bitacora_recaudacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Tbv_bitacora_recaudacion[]) list.toArray(new Tbv_bitacora_recaudacion[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion loadTbv_bitacora_recaudacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_recaudacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion loadTbv_bitacora_recaudacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return loadTbv_bitacora_recaudacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion loadTbv_bitacora_recaudacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Tbv_bitacora_recaudacion[] tbv_bitacora_recaudacions = listTbv_bitacora_recaudacionByQuery(session, condition, orderBy);
		if (tbv_bitacora_recaudacions != null && tbv_bitacora_recaudacions.length > 0)
			return tbv_bitacora_recaudacions[0];
		else
			return null;
	}
	
	public Tbv_bitacora_recaudacion loadTbv_bitacora_recaudacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Tbv_bitacora_recaudacion[] tbv_bitacora_recaudacions = listTbv_bitacora_recaudacionByQuery(session, condition, orderBy, lockMode);
		if (tbv_bitacora_recaudacions != null && tbv_bitacora_recaudacions.length > 0)
			return tbv_bitacora_recaudacions[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateTbv_bitacora_recaudacionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return iterateTbv_bitacora_recaudacionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_bitacora_recaudacionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Bdvendomaticav04PersistentManager.instance().getSession();
			return iterateTbv_bitacora_recaudacionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_bitacora_recaudacionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_recaudacion as Tbv_bitacora_recaudacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTbv_bitacora_recaudacionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tbv_bitacora_recaudacion as Tbv_bitacora_recaudacion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion createTbv_bitacora_recaudacion() {
		return new orm.Tbv_bitacora_recaudacion();
	}
	
	public boolean save(orm.Tbv_bitacora_recaudacion tbv_bitacora_recaudacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().saveObject(tbv_bitacora_recaudacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Tbv_bitacora_recaudacion tbv_bitacora_recaudacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().deleteObject(tbv_bitacora_recaudacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tbv_bitacora_recaudacion tbv_bitacora_recaudacion)throws PersistentException {
		try {
			if(tbv_bitacora_recaudacion.getTbv_bitacora_maquinabm_id_bitacora_maquina() != null) {
				tbv_bitacora_recaudacion.getTbv_bitacora_maquinabm_id_bitacora_maquina().tbv_bitacora_recaudacion.remove(tbv_bitacora_recaudacion);
			}
			
			orm.Tbv_captura[] lTbv_capturas = tbv_bitacora_recaudacion.tbv_captura.toArray();
			for(int i = 0; i < lTbv_capturas.length; i++) {
				lTbv_capturas[i].setTbv_bitacora_recaudacionbr_id_bitacora_recaudacion(null);
			}
			return delete(tbv_bitacora_recaudacion);
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tbv_bitacora_recaudacion tbv_bitacora_recaudacion, org.orm.PersistentSession session)throws PersistentException {
		try {
			if(tbv_bitacora_recaudacion.getTbv_bitacora_maquinabm_id_bitacora_maquina() != null) {
				tbv_bitacora_recaudacion.getTbv_bitacora_maquinabm_id_bitacora_maquina().tbv_bitacora_recaudacion.remove(tbv_bitacora_recaudacion);
			}
			
			orm.Tbv_captura[] lTbv_capturas = tbv_bitacora_recaudacion.tbv_captura.toArray();
			for(int i = 0; i < lTbv_capturas.length; i++) {
				lTbv_capturas[i].setTbv_bitacora_recaudacionbr_id_bitacora_recaudacion(null);
			}
			try {
				session.delete(tbv_bitacora_recaudacion);
				return true;
			} catch (Exception e) {
				return false;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Tbv_bitacora_recaudacion tbv_bitacora_recaudacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().getSession().refresh(tbv_bitacora_recaudacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Tbv_bitacora_recaudacion tbv_bitacora_recaudacion) throws PersistentException {
		try {
			orm.Bdvendomaticav04PersistentManager.instance().getSession().evict(tbv_bitacora_recaudacion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tbv_bitacora_recaudacion loadTbv_bitacora_recaudacionByCriteria(Tbv_bitacora_recaudacionCriteria tbv_bitacora_recaudacionCriteria) {
		Tbv_bitacora_recaudacion[] tbv_bitacora_recaudacions = listTbv_bitacora_recaudacionByCriteria(tbv_bitacora_recaudacionCriteria);
		if(tbv_bitacora_recaudacions == null || tbv_bitacora_recaudacions.length == 0) {
			return null;
		}
		return tbv_bitacora_recaudacions[0];
	}
	
	public Tbv_bitacora_recaudacion[] listTbv_bitacora_recaudacionByCriteria(Tbv_bitacora_recaudacionCriteria tbv_bitacora_recaudacionCriteria) {
		return tbv_bitacora_recaudacionCriteria.listTbv_bitacora_recaudacion();
	}
}
